import json

def load_json_as_dict(file_path):
    with open(file_path, 'r',) as f:
        data = json.load(f)
    return data

# 示例使用
file_path = '202501\\imagenet_classes.json'
synset_dict = load_json_as_dict(file_path)

# 打印字典内容
print(synset_dict['n07753275'])

# 读取 txt 文件中的键
txt_file = '202501\\imagenet_classes_name.txt'  # TXT 文件路径
with open(txt_file, 'r') as f:
    txt_keys = f.read().splitlines()  # 每行一个键

# 验证是否所有键都出现在字典中
missing_keys = [key for key in txt_keys if key not in synset_dict]

if missing_keys:
    print(f"以下键不在字典中: {missing_keys}")
else:
    print("所有键均出现在字典中！")